package com.chapter10.final_;

/**
 * 如果不希望类或类中的属性被改变（继承，赋值、重写）
 * 可以用final修饰符来定义
 * */
public class Final01 {

    public static void main(String[] args) {
        MJ mj = new MJ(3);
        System.out.println("面积为"+mj.Mj());
    }
}
class MJ{
    private final double radius;
    private final double PI;// = 3.14;
    {
//        PI = 3.14;
    }
    public  MJ(double radius) {
        this.radius = radius;
        PI = 3.14; 
    }

    public double Mj(){
        return radius*radius*PI;
    }
}
class BB extends MJ{
    public BB(double radius) {
        super(radius);
    }

}

